home *** CD-ROM | disk | FTP | other *** search
- FRAMES
- -------------------------------------------------------------------
-
- Frames are the core items to the window manager. You create a frame
- using a pushimage then save the global variable stackptr to
- manipulate it and to recognise it. stackptr is of the TYPE
- imagestackptr. Since this is a pointer it will always be unique to
- the frame.
-
- Here we create a frame that covers the area (50,50,200,150) on the
- screen.
-
- BEGINFILE> frame1.c
- /* -- frame1.c */
-
- #include "teglsys.h"
-
- imagestkptr ifs;
-
-
- void main(void)
- {
-
-
- easytegl();
- easyout();
- pushimage(50,50,200,150);
- ifs = stackptr;
- teglsupervisor();
- }
-
-
-
- ENDFILE>
-
-
- Notice that we start our program with tegleasy and easyout. It's a
- good idea to start your programs this way when you are first
- learning how to use the TEGL WINDOWS TOOLKIT because they provide a
- simplified startup and a way to exit the program.
-
- Specifically tegleasy initializes the graphics system (autodectects
- the graphics hardware), the virtual memory manager, the window
- manager and it clears the screen too! Easyout places a button in
- the lower left corner of the screen that will terminate the program
- when it is clicked on. This may seem trivial but in a GUI there has
- to be an event to make the program finish, teglsupervisor never
- returns, it just loops waiting for an event.
-
- This little program isn't very useful yet because all we have done
- is saved the area that this frame covers. If you run it you won't
- see anything on the screen to show where the frame is. However, if
- you click the right mouse button down and move it around the screen
- will will find that there is an invisible frame there that can been
- moved. The right mouse button can be used to click on and move any
- mobile frame. Lets change it by covering it with something so we
- can see it.
-
-
- BEGINFILE> frame2.c
- /* -- frame2.c */
-
- #include "teglsys.h"
-
- imagestkptr ifs;
-
-
- void main(void)
- {
-
-
- easytegl();
- easyout();
- pushimage(50,50,200,150);
- shadowbox(50,50,200,150);
- ifs = stackptr;
- teglsupervisor();
- }
-
-
-
- ENDFILE>
-
-
- Here we have added a line calling the routine shadowbox. This just
- blanks the frame and places a shadowed edge around it. You could
- clear the frame by using the bar command like so:
-
- setviewport(0,0,getmaxx(),getmaxy(),0);
- setfillstyle(SOLID_FILL,WHITE);
- bar(50,50,200,150);
- setcolor(BLACK);
- rectangle(50,50,200,150);
-
- This would blank the frame to white and draw a black line around
- it. shawdowbox isn't much more complicated, but it is ready to use.
-
- You're probably wondering why we keep saving the stackptr. Like we
- said earlier, you'll need this to manipulate the frame. So lets use
- it.
-
- The next example adds a button and an associated event to the
- frame.
-
-
- BEGINFILE> frame3.c
- /* -- frame3.c */
-
- #include "teglsys.h"
-
- imagestkptr ifs;
-
-
- unsigned cancelevent(imagestkptr frame, msclickptr mouse)
- {
- dropstackimage(ifs);
- return 0;
- }
-
-
- void main(void)
- {
-
-
- easytegl();
- easyout();
- pushimage(50,50,200,150);
- shadowbox(50,50,200,150);
- ifs = stackptr;
- definesquarebuttontext(ifs,0,0,80,30,5,5,"CANCEL",cancelevent);
- teglsupervisor();
- }
-
-
-
- ENDFILE>
-
-
- After compiling and running this you'll probably agree that those
- squarebuttons look OK.
-
- Now lets add some action to it. This example will press and release
- the button. Try holding the left mouse button down and passing it
- over the button repeatedly.
-
- BEGINFILE> frame4.c
- /* -- frame4.c */
-
- #include "teglsys.h"
-
- imagestkptr ifs;
-
-
- unsigned cancelevent(imagestkptr frame, msclickptr mouse)
- {
- /* -- this will press the button down and if the mouse button */
- /* -- is release WHILE it is over the button it will return */
- /* -- TRUE. If the mouse cursor passes out of the button without */
- /* -- being released then it will return FALSE and */
- /* -- releasesquarebutton will be called automatically. */
- if (visualsquarebuttonpress(frame,mouse))
- {
- /* -- was TRUE, we release the button */
- releasesquarebutton(frame,mouse);
- /* -- then dispose of the frame. */
- dropstackimage(ifs);
- }
- return 0;
- }
-
-
- void main(void)
- {
-
-
- easytegl();
- easyout();
- pushimage(50,50,200,150);
- shadowbox(50,50,200,150);
- ifs = stackptr;
- definesquarebuttontext(ifs,0,0,70,30,5,5,"CANCEL",cancelevent);
- teglsupervisor();
- }
-
-
-
- ENDFILE>
-
- At some point you will likely have more than one frame on the
- screen. When the mouse clicks on that frame it would be nice to
- have it on top of all the other frames.
-
- setautorotate(OnOff: Boolean);
-
- This sets the automatic rotation of frames. If set to TRUE then any
- frame that is clicked on will come to the top of the stack (be the
- topmost, and entirely visible).
-
- This example will put 25 frames on the screen. Try running it with
- autorotate set to FALSE also. Try moving the frames around (using
- the right mouse button).
-
- BEGINFILE> frame5.c
- /* -- frame5.c */
-
- #include "teglsys.h"
-
-
- unsigned cancelevent(imagestkptr frame, msclickptr mouse)
- {
- if (visualsquarebuttonpress(frame,mouse))
- {
- /* -- was TRUE, we release the button */
- releasesquarebutton(frame,mouse);
- /* -- then dispose of the frame. */
- dropstackimage(frame);
- }
- return 0;
- }
-
- imagestkptr ifs;
- int i;
- unsigned x1, y1, x2, y2;
-
-
- void main(void)
- {
-
-
- easytegl();
- easyout();
- setautorotate(TRUE);
- for (i = 1; i <= 25; i++)
- {
- x1 = i * 10;
- y1 = i * 10;
- x2 = 150;
- y2 = 100;
- quickframe(&ifs,&x1,&y1,&x2,&y2);
- definesquarebuttontext(ifs,0,0,70,30,5,5,"CANCEL",cancelevent);
- }
- teglsupervisor();
- }
-
-
-
- ENDFILE>
-
-
-